<template>
	<view>
		<app-header :title="title"></app-header>
		<!-- <view class="title">
			{{title}}
		</view> -->
		<view class="content">
			<rich-text :nodes="content"></rich-text>
		</view>

	</view>
</template>

<script>
	import {
		getToken
	} from '@/utils/auth'
	export default {
		data() {
			return {
				title: "",
				content: "",
				id: ''
			}
		},
		onLoad(option) {
			this.id = option.id
			if (option.id) {
				this.getInfo()
			}

		},
		methods: {
			getInfo() {
				const api = getToken() ? '/data/api.auth.User/newscView' : '/data/api.News/newscView'
				this.$http.post(api, {
					id: this.id
				}).then(res => {
					this.title = res.data.title
					uni.setNavigationBarTitle({
						title: this.title
					})
					// this.content = res.data.content 
					this.content = res.data.content.replace(/\<img/gi,
						'<img style="max-width:100%;height:auto;display:block;"');
				})
			}
		},

	}
</script>

<style scoped lang="scss">
	.title {
		font-size: 30rpx;
		font-weight: bold;
		margin: 37rpx 31rpx;
		text-align: center;
	}

	.content {
		margin: 37rpx 31rpx;
		font-size: 28rpx;

		::v-deep img {
			max-width: 100%;
		}
	}
</style>